<h1>Products List</h1>

<div id="admin_icon_edit">
<li><?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl.'/images/icons/icon_add2.png'). ' Create Product', array('products/create', 'productCategoryId' => $productCategoryModel->id));?></li>
</div>

<?php  $this->widget('zii.widgets.grid.CGridView', array(
    'dataProvider'=>$dataProvider,
    'columns'=>array(
      array(
        'header'=>'No.',
        'value'=>'$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
      ),
      array(
        'name' => 'Photo',
        'type' => 'raw',
        'value' => 'isset($data->default_photo_id) ? CHtml::image(Yii::app()->request->baseUrl.$data->defaultPhoto->thumbnailPath) : ""'
      ),
      'name_en',
      array(
        'name' => 'Photo Gallery',
        'type' => 'raw',
        'value' => 'CHtml::link("Photo ($data->photosCount)",Yii::app()->createUrl("productPhotos/list", array("productId"=>$data->id)))'
      ),
      array(
        'header' => 'Display Order',
        'class'=>'CButtonColumn',
        'template'=>'{up} {down}',
        'buttons' => array(
          'up' => array
          (
            'label'=>'up image',
            'visible'=>'$data->display_order > 1',
            'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/icon_up.png',
            'url'=>'Yii::app()->createUrl("products/upDisplay", array("id"=>$data->id))',
          ),
          'down' => array
          (
            'label'=>'down image',
            'visible'=>'$data->display_order < $data->maxDisplayOrder',
            'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/icon_down.png',
            'url'=>'Yii::app()->createUrl("products/downDisplay", array("id"=>$data->id))',
          ),
        )
      ),
      array(
        'header'=>'Enable',
        'class'=>'CButtonColumn',
        'template'=>'{enable} {disable}',
        'buttons'=>array(
          'enable' => array(
            'imageUrl' => Yii::app()->request->baseUrl.'/images/icons/icon_enable.jpg',
            'visible'=>'$data->enable == true',
            'url'=>'Yii::app()->createUrl("products/updateStatus", array("id"=>$data->id))',
            'click'=>'function(){if (confirm("Do you want to disable this data?")){return true; }else { return false;}}',
          ),
          'disable' => array(
            'imageUrl' => Yii::app()->request->baseUrl.'/images/icons/icon_disable.jpg',
            'visible'=>'$data->enable == false',
            'url'=>'Yii::app()->createUrl("products/updateStatus", array("id"=>$data->id))',
            'click'=>'function(){if (confirm("Do you want to enable this data?")){return true; }else { return false;}}',
          )
        ),
      ),
      array(
        'header'=>'Feature',
        'class'=>'CButtonColumn',
        'template'=>'{feature} {unfeature}',
        'buttons'=>array(
          'feature' => array(
            'imageUrl' => Yii::app()->request->baseUrl.'/images/icons/icon_enable.jpg',
            'visible'=>'$data->feature == true',
            'url'=>'Yii::app()->createUrl("products/updateFeature", array("id"=>$data->id))',
            'click'=>'function(){if (confirm("Do you want to unfeature this data?")){return true; }else { return false;}}',
          ),
          'unfeature' => array(
            'imageUrl' => Yii::app()->request->baseUrl.'/images/icons/icon_disable.jpg',
            'visible'=>'$data->feature == false',
            'url'=>'Yii::app()->createUrl("products/updateFeature", array("id"=>$data->id))',
            'click'=>'function(){if (confirm("Do you want to feature this data?")){return true; }else { return false;}}',
          )
        ),
      ),      
      array(
        'header'=>'Edit',
        'class'=>'CButtonColumn',
        'template'=>'{update}',
        'buttons'=>array(
          'update' => array(
            'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/icon_edit.jpg',
          )
        ),
      ),
      array(
        'header'=>'Delete',
        'class'=>'CButtonColumn',
        'template'=>'{delete}',
        'buttons'=>array(
          'delete' => array(
            'imageUrl'=>Yii::app()->request->baseUrl.'/images/icons/icon_bin.jpg',
          )
        ),
      ),
    ),
  )); ?>
